package com.chrray.position.enums.app;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.math3.util.Pair;

/**
 * 期望薪资:
 * 1-面议
 * 2-1000元以下
 * 3-1000-2000元
 * 4-2000-3000元
 * 5-3000-5000元
 * 6-5000-8000元
 * 7-8000-12000元
 * 8-12000-20000元
 * 9-20000-25000元
 * 10-25000元以上
 */
public enum FdSalaryRangeEnum implements BaseEnum{
    /**
     * 面议
     */
    NEGOTIABLE(1, "面议"),
    /**
     * 1000元以下
     */
    BELOW_1000(2, "1000元以下"),
    /**
     * 1000-2000元
     */
    BETWEEN_1000_2000(3, "1000-2000元"),
    /**
     * 2000-3000元
     */
    BETWEEN_2000_3000(4, "2000-3000元"),
    /**
     * 3000-5000元
     */
    BETWEEN_3000_5000(5, "3000-5000元"),
    /**
     * 5000-8000元
     */
    BETWEEN_5000_8000(6, "5000-8000元"),
    /**
     * 8000-12000元
     */
    BETWEEN_8000_12000(7, "8000-12000元"),
    /**
     * 12000-20000元
     */
    BETWEEN_12000_20000(8, "12000-20000元"),
    /**
     * 20000-25000元
     */
    BETWEEN_20000_25000(9, "20000-25000元"),
    /**
     * 25000元以上
     */
    ABOVE_25000(10, "25000元以上")
    ;

    @JsonValue
    @EnumValue
    private final Integer value;
    private final String info;

    FdSalaryRangeEnum(Integer value, String info) {
        this.info = info;
        this.value = value;
    }

    public Pair<Integer,Integer> getSalaryRange(){
        switch (this){
            case NEGOTIABLE:
                return new Pair<>(0,0);
            case BELOW_1000:
                return new Pair<>(0,1000);
            case BETWEEN_1000_2000:
                return new Pair<>(1000,2000);
            case BETWEEN_2000_3000:
                return new Pair<>(2000,3000);
            case BETWEEN_3000_5000:
                return new Pair<>(3000,5000);
            case BETWEEN_5000_8000:
                return new Pair<>(5000,8000);
            case BETWEEN_8000_12000:
                return new Pair<>(8000,12000);
            case BETWEEN_12000_20000:
                return new Pair<>(12000,20000);
            case BETWEEN_20000_25000:
                return new Pair<>(20000,25000);
            case ABOVE_25000:
                return new Pair<>(25000,Integer.MAX_VALUE);
            default:
                return new Pair<>(0,0);
        }
    }

    @JsonCreator
    public static FdSalaryRangeEnum getByValue(Integer value) {
        for (FdSalaryRangeEnum en : FdSalaryRangeEnum.values()) {
            if (en.getValue().equals(value)) {
                return en;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }

    public String getInfo() {
        return info;
    }
}
